package thread.线程的创建;

public class 等待线程 {
    public static void main(String[] args) throws InterruptedException {
        Thread t = new Thread(()-> {
            for (int i = 0; i < 5; i++) {
                System.out.println("t线程进行");
                try {
                    Thread.sleep(1000);
                } catch (InterruptedException e) {
                    throw new RuntimeException(e);
                }
            }
        });

        t.start();

        System.out.println("join等待开始");

        //等待 t 线程结束再并发执行下面的线程
        t.join();

        System.out.println("join等待结束");
    }
}
